BreadPlan Science!

This is where I'm doing the calculations that go into BreadPlan


In [19]:
# Densities for flour types in grams/cup according to different sources
# USDA and Gold Medal from http://www.weekendbakery.com/cooking-conversions/
# King Arthur from http://www.kingarthurflour.com/recipe/master-weight-chart.html 
# (rounded to nearest gram)
whole_wheat = {
               "USDA": 125,
               "Gold Medal": 128,
               "King Arthur": 113,
               }
all_purpose = {
               "USDA": 125,
               "Gold Medal": 130,
               "King Arthur": 120
               }
bread_flour = {
               "USDA": 127,
               "Gold Medal": 135,
               "King Arthur": 120
               }
rye         = {
               "USDA": 102,
                # couldn't find Gold Medal's reported density for rye flour (do they make it?)
               "King Arthur Medium Rye": 103,
               "King Arthur White Rye": 106
               }

In [4]:
import numpy

In [24]:
values = lambda flour: [grams for key, grams in flour.iteritems() if key not in ["average", "std"]]

In [25]:
# Compute average density
whole_wheat["average"] = numpy.mean(values(whole_wheat))
all_purpose["average"] = numpy.mean(values(all_purpose))
bread_flour["average"] = numpy.mean(values(bread_flour))
rye["average"] = numpy.mean(values(rye))

In [26]:
# Compute standard deviations
whole_wheat["std"] = numpy.std(values(whole_wheat))
all_purpose["std"] = numpy.std(values(all_purpose))
bread_flour["std"] = numpy.std(values(bread_flour))
rye["std"] = numpy.std(values(rye))

In [27]:
whole_wheat


Out[27]:
{'Gold Medal': 128,
 'King Arthur': 113,
 'USDA': 125,
 'average': 122.0,
 'std': 6.4807406984078604}

In [28]:
all_purpose


Out[28]:
{'Gold Medal': 130,
 'King Arthur': 120,
 'USDA': 125,
 'average': 125.0,
 'std': 4.0824829046386304}

In [29]:
bread_flour


Out[29]:
{'Gold Medal': 135,
 'King Arthur': 120,
 'USDA': 127,
 'average': 127.33333333333333,
 'std': 6.1282587702834119}

In [30]:
rye


Out[30]:
{'King Arthur Medium Rye': 103,
 'King Arthur White Rye': 106,
 'USDA': 102,
 'average': 103.66666666666667,
 'std': 1.699673171197595}

In [2]:
# A nice simple percentage function
percentage = lambda part, whole: (part * whole) / 100.0

In [4]:
# Eggs!
large_egg = 54.4 # USDA large egg (this is American)
shell = percentage(13, large_egg) #


Out[4]:
7.071999999999999

In [ ]: